<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Get inference trained model API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'get-inference.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/get-inference.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/get-inference.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/get-inference.html" rel="nofollow" target="_blank">../en/get-inference.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="ml-df-analytics-apis.html">Machine learning data frame analytics APIs</a></span>
»
<span class="breadcrumb-node">Get inference trained model API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="get-dfanalytics-stats.html">« Get data frame analytics jobs statistics API</a>
</span>
<span class="next">
<a href="get-inference-stats.html">Get inference trained model statistics API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="get-inference"></a>Get inference trained model API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Retrieves configuration information for a trained inference model.</p>
<div class="warning admon">
<div class="icon"></div>
<div class="admon_content">
<p>This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET _ml/inference/</code><br></p>
<p><code class="literal">GET _ml/inference/&lt;model_id&gt;</code><br></p>
<p><code class="literal">GET _ml/inference/_all</code><br></p>
<p><code class="literal">GET _ml/inference/&lt;model_id1&gt;,&lt;model_id2&gt;</code><br></p>
<p><code class="literal">GET _ml/inference/&lt;model_id_pattern*&gt;</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-prereq"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Required privileges which should be added to a custom role:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
cluster: <code class="literal">monitor_ml</code>
</li>
</ul>
</div>
<p>For more information, see <a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a> and <a class="xref" href="built-in-roles.html" title="Built-in roles">Built-in roles</a>.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can get information for multiple trained models in a single API request by
using a comma-separated list of model IDs or a wildcard expression.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;model_id&gt;</code>
</span>
</dt>
<dd>
(Optional, string)
The unique identifier of the trained inference model.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">allow_no_match</code>
</span>
</dt>
<dd>
<p>
(Optional, boolean)
 Specifies what to do when the request:
</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Contains wildcard expressions and there are no data frame analytics jobs that match.
</li>
<li class="listitem">
Contains the <code class="literal">_all</code> string or no identifiers and there are no matches.
</li>
<li class="listitem">
Contains wildcard expressions and there are only partial matches.
</li>
</ul>
</div>
<p>The default value is <code class="literal">true</code>, which returns an empty <code class="literal">data_frame_analytics</code> array
when there are no matches and the subset of results when there are partial
matches. If this parameter is <code class="literal">false</code>, the request returns a <code class="literal">404</code> status code
when there are no matches or only partial matches.</p>
</dd>
<dt>
<span class="term">
<code class="literal">decompress_definition</code>
</span>
</dt>
<dd>
(Optional, boolean)
Specifies whether the included model definition should be returned as a JSON map
(<code class="literal">true</code>) or in a custom compressed format (<code class="literal">false</code>). Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">from</code>
</span>
</dt>
<dd>
(Optional, integer)
Skips the specified number of data frame analytics jobs. The default value is <code class="literal">0</code>.
</dd>
<dt>
<span class="term">
<code class="literal">include_model_definition</code>
</span>
</dt>
<dd>
(Optional, boolean)
Specifies if the model definition should be returned in the response. Defaults
to <code class="literal">false</code>. When <code class="literal">true</code>, only a single model must match the ID patterns
provided, otherwise a bad request is returned.
</dd>
<dt>
<span class="term">
<code class="literal">size</code>
</span>
</dt>
<dd>
(Optional, integer)
Specifies the maximum number of data frame analytics jobs to obtain. The default value
is <code class="literal">100</code>.
</dd>
<dt>
<span class="term">
<code class="literal">tags</code>
</span>
</dt>
<dd>
(Optional, string)
A comma delimited string of tags. A inference model can have many tags, or none.
When supplied, only inference models that contain all the supplied tags are
returned.
</dd>
</dl>
</div>
</div>

<div class="section child_attributes">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-results"></a>Response body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">trained_model_configs</code>
</span>
</dt>
<dd>
<p>
(array)
An array of trained model resources, which are sorted by the <code class="literal">model_id</code> value in
ascending order.
</p>
<details open>
<summary class="title">Properties of trained model resources</summary>
<div class="content">
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">created_by</code>
</span>
</dt>
<dd>
(string)
Information on the creator of the trained model.
</dd>
<dt>
<span class="term">
<code class="literal">create_time</code>
</span>
</dt>
<dd>
(<a class="xref" href="common-options.html#time-units" title="Time units">time units</a>)
The time when the trained model was created.
</dd>
<dt>
<span class="term">
<code class="literal">default_field_map</code>
</span>
</dt>
<dd>
<p>
(object)
A string to string object that contains the default field map to use
when inferring against the model. For example, data frame analytics
may train the model on a specific multi-field <code class="literal">foo.keyword</code>.
The analytics job would then supply a default field map entry for
<code class="literal">"foo" : "foo.keyword"</code>.
</p>
<p>Any field map described in the inference configuration takes precedence.</p>
</dd>
<dt>
<span class="term">
<code class="literal">estimated_heap_memory_usage_bytes</code>
</span>
</dt>
<dd>
(integer)
The estimated heap usage in bytes to keep the trained model in memory.
</dd>
<dt>
<span class="term">
<code class="literal">estimated_operations</code>
</span>
</dt>
<dd>
(integer)
The estimated number of operations to use the trained model.
</dd>
<dt>
<span class="term">
<code class="literal">license_level</code>
</span>
</dt>
<dd>
(string)
The license level of the trained model.
</dd>
<dt>
<span class="term">
<code class="literal">metadata</code>
</span>
</dt>
<dd>
(object)
An object containing metadata about the trained model. For example, models
created by data frame analytics contain <code class="literal">analysis_config</code> and <code class="literal">input</code> objects.
</dd>
<dt>
<span class="term">
<code class="literal">model_id</code>
</span>
</dt>
<dd>
(string)
Idetifier for the trained model.
</dd>
<dt>
<span class="term">
<code class="literal">tags</code>
</span>
</dt>
<dd>
(string)
A comma delimited string of tags. A inference model can have many tags, or none.
</dd>
<dt>
<span class="term">
<code class="literal">version</code>
</span>
</dt>
<dd>
(string)
The Elasticsearch version number in which the trained model was created.
</dd>
</dl>
</div>
</div>
</details>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-response-codes"></a>Response codes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">400</code>
</span>
</dt>
<dd>
If <code class="literal">include_model_definition</code> is <code class="literal">true</code>, this code indicates that more than
one models match the ID pattern.
</dd>
<dt>
<span class="term">
<code class="literal">404</code> (Missing resources)
</span>
</dt>
<dd>
If <code class="literal">allow_no_match</code> is <code class="literal">false</code>, this code indicates that there are no
resources that match the request or only partial matches for the request.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-inference-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The following example gets configuration information for all the trained models:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _ml/inference/</pre>
</div>
<div class="console_widget" data-snippet="snippets/1859.console"></div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="get-dfanalytics-stats.html">« Get data frame analytics jobs statistics API</a>
</span>
<span class="next">
<a href="get-inference-stats.html">Get inference trained model statistics API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>